
#include "LuaCurl.h"

using namespace LuaGui;

#if defined(USE_CURL_FALSE)

void LuaCurl::OnFinish(std::string data)
{
	//LuaCpp::CallLuaGlobalFunction("__on_curl__", GetUID());
	//CallLuaGlobalFunction(LuaCpp::s_main_luacpp->GetLuaState(), "__on_curl__", GetUID(), data);
	Application::GetInstance()->OnCurl(GetUID(), data);
}

static LuaCurl* NewLuaCurl()
{
	return new LuaCurl();
}

static void DeleteLuaCurl(LuaCurl* luacurl)
{
	delete luacurl;
}
void LuaCurl::Register(lua_State* L)
{
	luabridge::getGlobalNamespace(L)
		.addFunction("NewLuaCurl", NewLuaCurl)
		.addFunction("DeleteLuaCurl", DeleteLuaCurl)
		.beginClass<Curl>("CppCurl")
		//.addConstructor <void (*) (void)>()
		.addFunction("GetUID", &Curl::GetUID)
		.addFunction("GetStatusCode", &Curl::GetStatusCode)
		.addFunction("AppendHeader", &Curl::AppendHeader)
		.addFunction("SetAuth", &Curl::SetAuth)
		.addFunction("Get", &Curl::Get)
		.addFunction("Put", &Curl::Put)
		.addFunction("Post", &Curl::Post)
		.addFunction("Delete", &Curl::Delete)
		.addFunction("Download", &Curl::Download)
		.addFunction("SendMail", &Curl::SendMail)
		.endClass()
		.deriveClass<LuaCurl, Curl>("LuaCurl")
		.endClass();
}
#endif